package cn.egame.extraction.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.egame.common.data.BaseDao;
import cn.egame.common.exception.ExceptionCommonBase;
import cn.egame.extraction.pojo.HdpRptClientV7ModelInfo;
import cn.egame.interfaces.ExceptionCommon;

public class HdpRptClientV7ModelDao extends BaseDao{

	private final static String STR_SELECCT_HDP_RPT_CLIENT_V7_MODEL = " model, uv, inserttime ";
	
	public static void main(String[] args) {
		try {
//			Connection conn = new HdpRptClientV7ModelDao().getConnection();
//			System.out.println(conn);
			
					BaseDao dao = new BaseDao("ttigame");
					dao.getConnection();
					System.out.println(dao.getConnection());
			
		} catch (ExceptionCommonBase e) {
			e.printStackTrace();
		}
		
	}
	
	public HdpRptClientV7ModelDao() throws ExceptionCommonBase {
		super("ttigame");
	}

	public List<HdpRptClientV7ModelInfo> listHdpRptClientV7ModelInfos() throws ExceptionCommonBase {
		List<HdpRptClientV7ModelInfo> hdpRptClientV7ModelInfoList = new ArrayList<HdpRptClientV7ModelInfo>();
		String sql = "select " + STR_SELECCT_HDP_RPT_CLIENT_V7_MODEL
				+ " from hdp_rpt_client_v7_model ";
		Connection conn = null;
		ResultSet rs = null;
		try {
		     conn = this.getConnection();
	         rs = this.executeQuery(conn, sql);
			while (rs.next()) {
				hdpRptClientV7ModelInfoList.add(formatHdpRptClientV7ModelInfo(rs));
			}
			return hdpRptClientV7ModelInfoList;
		} catch (SQLException e) {
			throw ExceptionCommon.throwExceptionCommonBase(e);
		} finally {
			this.close(rs);
			this.releaseConnection(conn);
		}
	}

	private HdpRptClientV7ModelInfo formatHdpRptClientV7ModelInfo(ResultSet rs) throws SQLException {
		int i = 1;
		HdpRptClientV7ModelInfo info = new HdpRptClientV7ModelInfo();
        info.setModel(rs.getString(i++));
        info.setNumber(rs.getInt(i++));
        info.setDate(rs.getDate(i++));
        return info;
	}
	
	
	
}
